/**
 * Jaxson ajax
 *
 * Copyright Remedy Interactive, licensed under Apache version 2 license:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0.html
 *
 * This notice must remain in all java source files.
 */
package org.jaxson.struts.encoder.excel;

import java.util.List;

import javax.servlet.ServletRequest;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

/**
 * Interface to control rendering of Excel data.
 * 
 * recommended reading:
 * http://poi.apache.org/spreadsheet/quick-guide.html
 * 
 * @author Joe Maisel
 */
public interface ExcelRenderer
{
	/**
	 * Called when the workbook is created. 
	 */
	void setWorkbook( HSSFWorkbook workbook );
	
	/**
	 * Called when the first sheet in the workbook is created. 
	 */
	void setDefaultSheet( HSSFSheet sheet );
	
	/**
	 * Called for each row in being rendered.
	 */
	void setCurrentRow( HSSFRow row );
	
	/**
	 * Get the row index used to create the current row
	 */
	int getRowIndex();
	
	/**
	 * Called for each cell being rendered.  The value of the method <code>getterName</code>
	 * is passed as <code>value</code> and <code>header</code> to determine if the row is header
	 */
	void setCurrentCell( HSSFCell cell, Object value, String getterName,boolean header );
	
	/**
	 * Get the list of getter methods in the order in which they'll be called 
	 * when creating a spreadsheet. 
	 */
	List<String> expose( List<String> getters );
	
	/**
	 * Lists the header names if header is displayed
	 * @param headerNames
	 * @return
	 */
	void headers(List<String> headerNames);
	
	/**
	 * if header row to be displayed for this workbook
	 * @param headerRow
	 * @return
	 */
	void setHeaderRow(boolean headerRow);
	
	/**
	 * Sheet name should be displayed
	 * @param sheetName
	 */
	void setSheetName(String sheetName);
	
	/**
	 * Lists the header names if header is displayed
	 * @param headerNames
	 * @return
	 */
	List<String> getHeaderNames();
	
	/**
	 * if header row to be displayed for this workbook
	 * @param headerRow
	 * @return
	 */
	boolean isHeaderRow();
	
	

	
	/**
	 * Sheet name should be displayed
	 * @param sheetName
	 */
	String getSheetName();
	
	
	/**
	 * Get the active sheet in the workbook.  If the desired outcome is to segregate
	 * instances into multiple sheets this method should return the sheet to use for the current row.
	 */
	HSSFSheet getActiveSheet();
	
	
	ServletRequest getRequest();
	
	void setRequest(ServletRequest request);
}
